<?php
declare (strict_types = 1);

namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;
class PurchaseGoodsOut extends Model
{
    use SoftDelete;
     protected $deleteTime = false;
    // 获取列表
    public static function getList()
    {
        $where = [];
        $limit = input('get.limit');
        
        $list = self::with([
            'get_goods' => function($a) {
                $a->field('id,goods_name');
            },
            'get_admin' => function($a) {
                $a->field('id,username');
            },
            'get_apply' => function($a) {
                $a->field('id,username');
            }
        ])->order('id','desc')->where($where)->paginate($limit);
        return ['code'=>0,'data'=>$list->items(),'extend'=>['count' => $list->total(), 'limit' => $limit]];
    }

    public function getGoods()
    {
        return $this->hasOne(PurchaseGoods::class, 'id', 'goods_id');
    }

    public function getAdmin()
    {
        return $this->hasOne(AdminAdmin::class, 'id', 'admin_id');
    }

    public function getApply()
    {
        return $this->hasOne(AdminAdmin::class, 'id', 'apply_id');
    }
}
